package com.xur.springboot.controller;

import com.xur.springboot.entity.internship;
import com.xur.springboot.service.InternshipService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class InternshipController {

    @Resource
    private InternshipService internshipService;
    //在鸿蒙前端获取数据时需要解析JSON数据
    //直接返回json数据
    @GetMapping("/internship")
    public List<internship> internship(){
        System.out.println("查询了实习职位列表");
        return internshipService.queryAllInternship();

    }

    @GetMapping("/internshipClass")
    public List<internship> queryBossInfoByRemark(@RequestParam String remark) {

        System.out.println("查询了职业分类实习、兼职、全职中的"+remark);
        return internshipService.queryBossInfoByRemark(remark);

    }


    @GetMapping("/internshipById")
    public List<internship> queryBossInfoById(@RequestParam int id) {

        System.out.println("根据id查询的id号："+id);
        return internshipService.queryBossInfoById(id);
    }

    @GetMapping("/createSimple")
    public String createSimple(
            @ModelAttribute internship entity,
            @RequestParam String detailContent) {
        System.out.println("我在这里");
        // 调用Service插入数据
        boolean success = internshipService.createInternshipWithDetail(entity, detailContent);
        return success ? "发布成功" : "发布失败";
    }

    @GetMapping("/internshipByUserDetailIds")
    public List<internship> queryByUserDetailIds(@RequestParam List<Integer> ids) {
        System.out.println("查询的 user_detail_id 列表：" + ids);
        return internshipService.queryByUserDetailIds(ids);
    }

}
